<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>CocoaPods 使用指南 | KnightSama‘s Blog</title>
    <meta name="description" content="Hello, my friend!">
    <link rel="icon" href="/favicon.ico">
  <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
  <script src="https://cdn.jsdelivr.net/npm/react/umd/react.production.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/react-dom/umd/react-dom.production.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/@babel/standalone/babel.min.js"></script>
    
    <link rel="preload" href="/assets/css/0.styles.c4ea52a5.css" as="style"><link rel="preload" href="/assets/js/app.a2483de7.js" as="script"><link rel="preload" href="/assets/js/4.0078dadf.js" as="script"><link rel="preload" href="/assets/js/1.c3e7d2b0.js" as="script"><link rel="preload" href="/assets/js/14.c27d4a17.js" as="script"><link rel="prefetch" href="/assets/js/10.265e4f40.js"><link rel="prefetch" href="/assets/js/11.a3a2f8c1.js"><link rel="prefetch" href="/assets/js/12.1910f8cc.js"><link rel="prefetch" href="/assets/js/13.229fa478.js"><link rel="prefetch" href="/assets/js/15.92adafd4.js"><link rel="prefetch" href="/assets/js/16.bcee7c14.js"><link rel="prefetch" href="/assets/js/17.ee1bcf41.js"><link rel="prefetch" href="/assets/js/18.fa3c3a4e.js"><link rel="prefetch" href="/assets/js/19.1a943c57.js"><link rel="prefetch" href="/assets/js/20.44781dae.js"><link rel="prefetch" href="/assets/js/21.1fe46223.js"><link rel="prefetch" href="/assets/js/22.6f7d46c2.js"><link rel="prefetch" href="/assets/js/23.56223d02.js"><link rel="prefetch" href="/assets/js/24.e7cad43b.js"><link rel="prefetch" href="/assets/js/25.b2902552.js"><link rel="prefetch" href="/assets/js/26.70698c07.js"><link rel="prefetch" href="/assets/js/27.6ee3d263.js"><link rel="prefetch" href="/assets/js/28.ce131de6.js"><link rel="prefetch" href="/assets/js/29.90552487.js"><link rel="prefetch" href="/assets/js/30.b3291ccc.js"><link rel="prefetch" href="/assets/js/31.ea8c441e.js"><link rel="prefetch" href="/assets/js/32.3e29bbeb.js"><link rel="prefetch" href="/assets/js/33.65e78c5e.js"><link rel="prefetch" href="/assets/js/34.3ba19d7c.js"><link rel="prefetch" href="/assets/js/35.66d3fc4a.js"><link rel="prefetch" href="/assets/js/36.f5725281.js"><link rel="prefetch" href="/assets/js/37.f5b0b5ff.js"><link rel="prefetch" href="/assets/js/38.3cae3054.js"><link rel="prefetch" href="/assets/js/39.47dc1ffe.js"><link rel="prefetch" href="/assets/js/5.f0714e2e.js"><link rel="prefetch" href="/assets/js/6.53240a5f.js"><link rel="prefetch" href="/assets/js/7.dc126a6b.js"><link rel="prefetch" href="/assets/js/8.86452400.js"><link rel="prefetch" href="/assets/js/9.16ef06de.js"><link rel="prefetch" href="/assets/js/vendors~flowchart.734d5d92.js">
    <link rel="stylesheet" href="/assets/css/0.styles.c4ea52a5.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div><div class="theme-container" data-v-0cb1c278><div data-v-0cb1c278><div id="loader-wrapper" class="loading-wrapper" data-v-4b73742e data-v-0cb1c278 data-v-0cb1c278><div class="loader-main" data-v-4b73742e><div data-v-4b73742e></div><div data-v-4b73742e></div><div data-v-4b73742e></div><div data-v-4b73742e></div></div> <!----> <!----></div> <div class="password-shadow password-wrapper-out" style="display:none;" data-v-da0660ba data-v-0cb1c278 data-v-0cb1c278><h3 class="title" style="display:none;" data-v-da0660ba data-v-da0660ba>KnightSama‘s Blog</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-da0660ba data-v-da0660ba><input type="password" value="" data-v-da0660ba> <span data-v-da0660ba>Konck! Knock!</span> <button data-v-da0660ba>OK</button></label> <div class="footer" style="display:none;" data-v-da0660ba data-v-da0660ba><span data-v-da0660ba><i class="iconfont reco-theme" data-v-da0660ba></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-da0660ba>vuePress-theme-reco</a></span> <span data-v-da0660ba><i class="iconfont reco-copyright" data-v-da0660ba></i> <a data-v-da0660ba><span data-v-da0660ba>KnightSama</span>
            
          <!---->
          2021
        </a></span></div></div> <div class="hide" data-v-0cb1c278><header class="navbar" data-v-0cb1c278><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/Misaka.jpg" alt="KnightSama‘s Blog" class="logo"> <span class="site-name">KnightSama‘s Blog</span></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">Choose mode</h4> <ul class="color-mode-options"><li class="dark">dark</li><li class="auto active">auto</li><li class="light">light</li></ul></div></div></div> <div class="search-box"><i class="iconfont reco-search"></i> <input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link"><i class="iconfont reco-home"></i>
  首页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      分类
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/iOS/" class="nav-link"><i class="iconfont undefined"></i>
  iOS
</a></li><li class="dropdown-item"><!----> <a href="/categories/集锦/" class="nav-link"><i class="iconfont undefined"></i>
  集锦
</a></li><li class="dropdown-item"><!----> <a href="/categories/JavaScript/" class="nav-link"><i class="iconfont undefined"></i>
  JavaScript
</a></li><li class="dropdown-item"><!----> <a href="/categories/Github/" class="nav-link"><i class="iconfont undefined"></i>
  Github
</a></li><li class="dropdown-item"><!----> <a href="/categories/Python/" class="nav-link"><i class="iconfont undefined"></i>
  Python
</a></li></ul></div></div><div class="nav-item"><a href="/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><a href="/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  时间线
</a></div><div class="nav-item"><a href="https://github.com/KnightSama" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>
  GitHub
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div> <!----></nav></div></header> <div class="sidebar-mask" data-v-0cb1c278></div> <aside class="sidebar" data-v-0cb1c278><div class="personal-info-wrapper" data-v-4a3def3c><img src="/Misaka.jpg" alt="author-avatar" class="personal-img" data-v-4a3def3c> <h3 class="name" data-v-4a3def3c>
    KnightSama
  </h3> <div class="num" data-v-4a3def3c><div data-v-4a3def3c><h3 data-v-4a3def3c>27</h3> <h6 data-v-4a3def3c>文章</h6></div> <div data-v-4a3def3c><h3 data-v-4a3def3c>14</h3> <h6 data-v-4a3def3c>标签</h6></div></div> <hr data-v-4a3def3c></div> <nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link"><i class="iconfont reco-home"></i>
  首页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      分类
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/iOS/" class="nav-link"><i class="iconfont undefined"></i>
  iOS
</a></li><li class="dropdown-item"><!----> <a href="/categories/集锦/" class="nav-link"><i class="iconfont undefined"></i>
  集锦
</a></li><li class="dropdown-item"><!----> <a href="/categories/JavaScript/" class="nav-link"><i class="iconfont undefined"></i>
  JavaScript
</a></li><li class="dropdown-item"><!----> <a href="/categories/Github/" class="nav-link"><i class="iconfont undefined"></i>
  Github
</a></li><li class="dropdown-item"><!----> <a href="/categories/Python/" class="nav-link"><i class="iconfont undefined"></i>
  Python
</a></li></ul></div></div><div class="nav-item"><a href="/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><a href="/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  时间线
</a></div><div class="nav-item"><a href="https://github.com/KnightSama" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>
  GitHub
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>CocoaPods 使用指南</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/Views/20160510.html#安装" class="sidebar-link">安装</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/Views/20160510.html#使用-rvm-安装-ruby" class="sidebar-link">使用 RVM 安装 Ruby</a></li><li class="sidebar-sub-header"><a href="/Views/20160510.html#使用-rbenv-安装-ruby" class="sidebar-link">使用 rbenv 安装 Ruby</a></li><li class="sidebar-sub-header"><a href="/Views/20160510.html#开始安装-cocoapods" class="sidebar-link">开始安装 CocoaPods</a></li></ul></li><li><a href="/Views/20160510.html#创建-podfile" class="sidebar-link">创建 Podfile</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/Views/20160510.html#添加平台" class="sidebar-link">添加平台</a></li><li class="sidebar-sub-header"><a href="/Views/20160510.html#通过-source-指定依赖库的来源" class="sidebar-link">通过 Source 指定依赖库的来源</a></li><li class="sidebar-sub-header"><a href="/Views/20160510.html#忽略引入库的所有警告" class="sidebar-link">忽略引入库的所有警告</a></li><li class="sidebar-sub-header"><a href="/Views/20160510.html#生成-framework-文件" class="sidebar-link">生成 framework 文件</a></li><li class="sidebar-sub-header"><a href="/Views/20160510.html#指定依赖项与版本号" class="sidebar-link">指定依赖项与版本号</a></li><li class="sidebar-sub-header"><a href="/Views/20160510.html#安装指定的模块" class="sidebar-link">安装指定的模块</a></li><li class="sidebar-sub-header"><a href="/Views/20160510.html#指定安装源" class="sidebar-link">指定安装源</a></li><li class="sidebar-sub-header"><a href="/Views/20160510.html#给指定的-target-添加依赖" class="sidebar-link">给指定的 target 添加依赖</a></li></ul></li><li><a href="/Views/20160510.html#常用指令" class="sidebar-link">常用指令</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/Views/20160510.html#搜索三方库" class="sidebar-link">搜索三方库</a></li><li class="sidebar-sub-header"><a href="/Views/20160510.html#更新本地依赖库列表" class="sidebar-link">更新本地依赖库列表</a></li><li class="sidebar-sub-header"><a href="/Views/20160510.html#安装依赖库" class="sidebar-link">安装依赖库</a></li></ul></li><li><a href="/Views/20160510.html#其他重要文件" class="sidebar-link">其他重要文件</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/Views/20160510.html#podfile-lock" class="sidebar-link">Podfile.lock</a></li><li class="sidebar-sub-header"><a href="/Views/20160510.html#podspec" class="sidebar-link">Podspec</a></li></ul></li></ul></section></li></ul> </aside> <div class="password-shadow password-wrapper-in" style="display:none;" data-v-da0660ba data-v-0cb1c278><h3 class="title" style="display:none;" data-v-da0660ba data-v-da0660ba>CocoaPods 使用指南</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-da0660ba data-v-da0660ba><input type="password" value="" data-v-da0660ba> <span data-v-da0660ba>Konck! Knock!</span> <button data-v-da0660ba>OK</button></label> <div class="footer" style="display:none;" data-v-da0660ba data-v-da0660ba><span data-v-da0660ba><i class="iconfont reco-theme" data-v-da0660ba></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-da0660ba>vuePress-theme-reco</a></span> <span data-v-da0660ba><i class="iconfont reco-copyright" data-v-da0660ba></i> <a data-v-da0660ba><span data-v-da0660ba>KnightSama</span>
            
          <!---->
          2021
        </a></span></div></div> <div data-v-0cb1c278><main class="page"><div class="sidebar-open-close"><svg xmlns="http://www.w3.org/2000/svg" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <!----> <div class="page-title" style="display:none;"><h1>CocoaPods 使用指南</h1> <hr> <div data-v-73367bb4><i class="iconfont reco-account" data-v-73367bb4><span data-v-73367bb4>KnightSama</span></i> <i class="iconfont reco-date" data-v-73367bb4><span data-v-73367bb4>2016-05-10</span></i> <i class="iconfont reco-eye" data-v-73367bb4><span id="/Views/20160510.html" data-flag-title="Your Article Title" class="leancloud-visitors" data-v-73367bb4><a class="leancloud-visitors-count" style="font-size:.9rem;font-weight:normal;color:#999;"></a></span></i> <i class="iconfont reco-tag tags" data-v-73367bb4><span class="tag-item" data-v-73367bb4>
      iOS
    </span></i></div></div> <div class="theme-reco-content content__default" style="display:none;"><p>CocoaPods 是常用的开发 iOS/macOS 程序的三方库依赖管理工具。通过 CocoaPods 我们可以定义自己的依赖关系，方便的对第三方库进行管理。
</p> <h2 id="安装"><a href="#安装" class="header-anchor">#</a> 安装</h2> <p>CocoaPods 是用 Ruby 语言编写，安装 CocoaPods 前我们需要先安装 Ruby，在此之前请确保已经安装 Homebrew</p> <p>MacOS 自带 Ruby 环境，但一般版本较低，我们可以通过 Ruby 版本管理工具来安装管理</p> <h3 id="使用-rvm-安装-ruby"><a href="#使用-rvm-安装-ruby" class="header-anchor">#</a> 使用 RVM 安装 Ruby</h3> <p>RVM 是开源的 Ruby 版本管理工具，可以管理多个 Ruby 版本并自由切换</p> <h4 id="安装-rvm"><a href="#安装-rvm" class="header-anchor">#</a> 安装 RVM</h4> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">curl</span> -L get.rvm.io <span class="token operator">|</span> <span class="token function">bash</span> -s stable
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h4 id="指定源"><a href="#指定源" class="header-anchor">#</a> 指定源</h4> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token builtin class-name">source</span> ~/.bashrc
<span class="token builtin class-name">source</span> ~/.bash_profile
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h4 id="查看-rvm-版本"><a href="#查看-rvm-版本" class="header-anchor">#</a> 查看 RVM 版本</h4> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>rvm -v
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h4 id="列出-ruby-可安装版本信息"><a href="#列出-ruby-可安装版本信息" class="header-anchor">#</a> 列出 Ruby 可安装版本信息</h4> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>rvm list known
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h4 id="安装需要安装的版本"><a href="#安装需要安装的版本" class="header-anchor">#</a> 安装需要安装的版本</h4> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>rvm <span class="token function">install</span> <span class="token number">2.6</span>.0
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h4 id="设置为默认版本"><a href="#设置为默认版本" class="header-anchor">#</a> 设置为默认版本</h4> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>rvm use <span class="token number">2.6</span>.0 --default
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h4 id="更换-gem-源"><a href="#更换-gem-源" class="header-anchor">#</a> 更换 gem 源</h4> <p>gem 默认的源国内无法连接，我们可以切换为镜像源</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>gem sources --remove https://rubygems.org/
gem sources --add https://gems.ruby-china.com/
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>更换完检查是否只有 ruby-china 一个源</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>gem sources -l
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="使用-rbenv-安装-ruby"><a href="#使用-rbenv-安装-ruby" class="header-anchor">#</a> 使用 rbenv 安装 Ruby</h3> <p>rbenv 与 RVM 一样也是常用的 Ruby 管理工具</p> <h4 id="安装-rbenv"><a href="#安装-rbenv" class="header-anchor">#</a> 安装 rbenv</h4> <p>我们可以直接使用 Homebrew 安装</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>brew <span class="token function">install</span> rbenv
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h4 id="在配置文件中初始化"><a href="#在配置文件中初始化" class="header-anchor">#</a> 在配置文件中初始化</h4> <p>如果用的 bash 脚本</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token builtin class-name">echo</span> <span class="token string">'export PATH=&quot;<span class="token environment constant">$HOME</span>/.rbenv/bin:<span class="token environment constant">$PATH</span>&quot;'</span> <span class="token operator">&gt;&gt;</span> ~/.bashrc
<span class="token builtin class-name">echo</span> <span class="token string">'eval &quot;<span class="token variable"><span class="token variable">$(</span>rbenv init -<span class="token variable">)</span></span>&quot;'</span> <span class="token operator">&gt;&gt;</span> ~/.bashrc
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>如果用的 zsh</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token builtin class-name">echo</span> <span class="token string">'export PATH=&quot;<span class="token environment constant">$HOME</span>/.rbenv/bin:<span class="token environment constant">$PATH</span>&quot;'</span> <span class="token operator">&gt;&gt;</span> ~/.zshrc
<span class="token builtin class-name">echo</span> <span class="token string">'eval &quot;<span class="token variable"><span class="token variable">$(</span>rbenv init -<span class="token variable">)</span></span>&quot;'</span> <span class="token operator">&gt;&gt;</span> ~/.zshrc
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h4 id="列出-ruby-可安装版本信息-2"><a href="#列出-ruby-可安装版本信息-2" class="header-anchor">#</a> 列出 Ruby 可安装版本信息</h4> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>rbenv <span class="token function">install</span> --list
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h4 id="安装需要安装的版本-2"><a href="#安装需要安装的版本-2" class="header-anchor">#</a> 安装需要安装的版本</h4> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>rbenv <span class="token function">install</span> <span class="token number">2.6</span>.0
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h4 id="设置版本"><a href="#设置版本" class="header-anchor">#</a> 设置版本</h4> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># 设置全局版本</span>
rbenv global <span class="token number">2.6</span>.0
<span class="token comment"># 设置本地版本</span>
rbenv <span class="token builtin class-name">local</span> <span class="token number">2.6</span>.0
<span class="token comment"># 设置当前终端版本</span>
rbenv shell <span class="token number">2.6</span>.0
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><div class="custom-block warning"><p class="custom-block-title">注意</p> <p>切换完版本后需要执行</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>rbenv rehash
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></div> <h3 id="开始安装-cocoapods"><a href="#开始安装-cocoapods" class="header-anchor">#</a> 开始安装 CocoaPods</h3> <p>安装完 Ruby 后我们就可以继续安装 CocoaPods</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> gem <span class="token function">install</span> -n /usr/local/bin cocoapods
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h4 id="安装本地库"><a href="#安装本地库" class="header-anchor">#</a> 安装本地库</h4> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>pod setup
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h4 id="设置仓库"><a href="#设置仓库" class="header-anchor">#</a> 设置仓库</h4> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> clone https://github.com/CocoaPods/Specs.git master --progress
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>如果速度太慢可以使用下面的镜像</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git  ~/.cocoapods/repos/trunk
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h4 id="最新版本的-cocoapods-默认使用-cdn-了，我们可以在-podfile-上添加"><a href="#最新版本的-cocoapods-默认使用-cdn-了，我们可以在-podfile-上添加" class="header-anchor">#</a> 最新版本的 CocoaPods 默认使用 CDN 了，我们可以在 Podfile 上添加</h4> <div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code>source <span class="token string">'https://cdn.cocoapods.org/'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>至此我们的 CocoaPods 就安装完毕了</p> <h2 id="创建-podfile"><a href="#创建-podfile" class="header-anchor">#</a> 创建 Podfile</h2> <p>Podfile 是一个文件，它通过 Ruby 的语法来描述依赖关系，定义项目所需要的三方库。我们通过配置这个文件来将指定版本的三方库或我们自己创建的私有库引入到工程中来。</p> <p>下面介绍了该文件的简单配置，更加详细的设置可以查看<a href="https://guides.cocoapods.org/syntax/podfile.html#podfile" target="_blank" rel="noopener noreferrer">官方文档<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></p> <h3 id="添加平台"><a href="#添加平台" class="header-anchor">#</a> 添加平台</h3> <p>下面指定了平台是 iOS，版本是 11.0</p> <div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code>platform <span class="token symbol">:ios</span><span class="token punctuation">,</span> <span class="token string">'11.0'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="通过-source-指定依赖库的来源"><a href="#通过-source-指定依赖库的来源" class="header-anchor">#</a> 通过  <code>Source</code>  指定依赖库的来源</h3> <p>如不写则是默认库，我们可以添加自己的私有库</p> <div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code>source <span class="token string">'https://github.com/CocoaPods/Specs.git'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="忽略引入库的所有警告"><a href="#忽略引入库的所有警告" class="header-anchor">#</a> 忽略引入库的所有警告</h3> <div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code>inhibit_all_warnings<span class="token operator">!</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="生成-framework-文件"><a href="#生成-framework-文件" class="header-anchor">#</a> 生成 framework 文件</h3> <p>导入 Swift 框架与动态库时需要添加</p> <div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code>use_frameworks<span class="token operator">!</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="指定依赖项与版本号"><a href="#指定依赖项与版本号" class="header-anchor">#</a> 指定依赖项与版本号</h3> <p>最简单的依赖声明，依赖指定项目的最新版本</p> <div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code>pod <span class="token string">'AFNetworking'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>通过添加版本号来依赖指定的版本</p> <div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code>pod <span class="token string">'AFNetworking'</span><span class="token punctuation">,</span> <span class="token string">'1.0.0'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>除了指定版本号，我们还可以通过下面的方式进行版本管理</p> <table><thead><tr><th style="text-align:center;">版本号</th> <th style="text-align:center;">描述</th></tr></thead> <tbody><tr><td style="text-align:center;">&gt;0.1</td> <td style="text-align:center;">高于 0.1 的任何版本</td></tr> <tr><td style="text-align:center;">&gt;=0.1</td> <td style="text-align:center;">0.1 和高于 0.1 的任何版本</td></tr> <tr><td style="text-align:center;">&lt;0.1</td> <td style="text-align:center;">低于 0.1 的任何版本</td></tr> <tr><td style="text-align:center;">&lt;=0.1</td> <td style="text-align:center;">0.1 和低于 0.1 的任何版本</td></tr> <tr><td style="text-align:center;">~&gt;0.1.1</td> <td style="text-align:center;">0.1.1 到 0.2 之间的最新版本，不包含 0.2</td></tr></tbody></table> <h3 id="安装指定的模块"><a href="#安装指定的模块" class="header-anchor">#</a> 安装指定的模块</h3> <p>默认情况下会安装所有定义在 Podspec 里面的默认模块 (Subspec)。我们可以通过下面的方式安装指定子模块</p> <div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code><span class="token comment"># 安装 Attribute 模块</span>
pod <span class="token string">'QueryKit/Attribute'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>可以通过下面的方式指定集合安装</p> <div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code>pod <span class="token string">'QueryKit'</span><span class="token punctuation">,</span> <span class="token symbol">:subspecs</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token punctuation">[</span><span class="token string">'Attribute'</span><span class="token punctuation">,</span> <span class="token string">'QuerySet'</span><span class="token punctuation">]</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="指定安装源"><a href="#指定安装源" class="header-anchor">#</a> 指定安装源</h3> <p>可以通过  <code>:git</code>  从指定的地址安装依赖项</p> <div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code>pod <span class="token string">'AFNetworking'</span><span class="token punctuation">,</span> <span class="token symbol">:git</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token string">'https://github.com/AFNetworking/AFNetworking.git'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>可以通过  <code>:branch</code>  指定分支</p> <div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code>pod <span class="token string">'AFNetworking'</span><span class="token punctuation">,</span> <span class="token symbol">:git</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token string">'https://github.com/AFNetworking/AFNetworking.git'</span><span class="token punctuation">,</span> <span class="token symbol">:branch</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token string">'dev'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>通过  <code>:tag</code>  指定某个 tag</p> <div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code>pod <span class="token string">'AFNetworking'</span><span class="token punctuation">,</span> <span class="token symbol">:git</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token string">'https://github.com/AFNetworking/AFNetworking.git'</span><span class="token punctuation">,</span> <span class="token symbol">:tag</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token string">'0.7.0'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><div class="custom-block warning"><p class="custom-block-title">注意</p> <p>通过上面的方式安装必须确保 podspec 文件存在于仓库的根目录中</p></div> <p>我们可以通过  <code>:podspec</code>  指定一个外部的 podspec 文件来引入一个不带 podspec 的库</p> <div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code>pod <span class="token string">'AFNetworking'</span><span class="token punctuation">,</span> <span class="token symbol">:podspec</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token string">'https://example.com/AFNetworking.podspec'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>可以通过  <code>:path</code>  来使用本地文件</p> <div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code>pod <span class="token string">'AFNetworking'</span><span class="token punctuation">,</span> <span class="token symbol">:path</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token string">'~/Documents/AFNetworking'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><div class="custom-block warning"><p class="custom-block-title">注意</p> <p>通过本地文件的方式安装必须确保 podspec 文件也在这个文件夹中</p></div> <h3 id="给指定的-target-添加依赖"><a href="#给指定的-target-添加依赖" class="header-anchor">#</a> 给指定的 target 添加依赖</h3> <p>下面的例子中给名称为 Demo 的 target 添加依赖</p> <div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code>target <span class="token string">'Demo'</span> <span class="token keyword">do</span>
    pod <span class="token string">'AFNetworking'</span>
<span class="token keyword">end</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><div class="custom-block warning"><p class="custom-block-title">注意</p> <p>如果我们不显式指定 target，CocoaPods 会创建一个名称为 default 的隐式 target 和工程中第一个 target 相对应，此时只有工程中第一个 target 能够使用 Pods 依赖库</p></div> <p>如果工程中有多个 target，并且存在重复的依赖项，例如 targetA 需要依赖 RxSwift、RxCocoa、SnapKit，targetB 需要依赖 RxSwift、RxCocoa、SwiftyJSON，其中 RxSwift、RxCocoa 是相同的依赖，则我们可以通过下面的三种方法来实现引入</p> <div class="tabs-component"><ul role="tablist" class="tabs-component-tabs"></ul> <div class="tabs-component-panels"><section aria-hidden="true" id="first-tab" role="tabpanel" class="tabs-component-panel" style="display:none;"><div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code><span class="token comment"># 这里的 abstract_pod 在实际 targets 中不存在，是虚拟的</span>
abstract_target <span class="token string">'abstract_pod'</span> <span class="token keyword">do</span>
    <span class="token comment"># 这里是公共的依赖项</span>
    pod <span class="token string">'RxSwift'</span>
    pod <span class="token string">'RxCocoa'</span>
    <span class="token comment"># 不同的 target 单独配置不同的依赖项</span>
    target <span class="token string">'targetA'</span> <span class="token keyword">do</span>
        pod <span class="token string">'SnapKit'</span>
    <span class="token keyword">end</span>
    
    target <span class="token string">'targetB'</span> <span class="token keyword">do</span>
        pod <span class="token string">'SwiftyJSON'</span>
    <span class="token keyword">end</span>
<span class="token keyword">end</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div></section> <section aria-hidden="true" id="second-tab" role="tabpanel" class="tabs-component-panel" style="display:none;"><div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code><span class="token comment"># 循环引入公共依赖</span>
targets <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">'targetA'</span><span class="token punctuation">,</span><span class="token string">'targetB'</span><span class="token punctuation">]</span>
targets<span class="token punctuation">.</span><span class="token keyword">each</span> <span class="token keyword">do</span> <span class="token operator">|</span>t<span class="token operator">|</span>
    target t <span class="token keyword">do</span>
        pod <span class="token string">'RxSwift'</span>
        pod <span class="token string">'RxCocoa'</span>
    <span class="token keyword">end</span>
<span class="token keyword">end</span>
<span class="token comment"># 不同的 target 单独配置不同的依赖项</span>
target <span class="token string">'targetA'</span> <span class="token keyword">do</span>
    pod <span class="token string">'SnapKit'</span>
<span class="token keyword">end</span>
    
target <span class="token string">'targetB'</span> <span class="token keyword">do</span>
    pod <span class="token string">'SwiftyJSON'</span>
<span class="token keyword">end</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br></div></div></section> <section aria-hidden="true" id="third-tab" role="tabpanel" class="tabs-component-panel" style="display:none;"><div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code><span class="token comment"># 定义公共 pods</span>
<span class="token keyword">def</span> <span class="token method-definition"><span class="token function">commonPods</span></span>
    pod <span class="token string">'RxSwift'</span>
    pod <span class="token string">'RxCocoa'</span>
<span class="token keyword">end</span>

<span class="token comment"># 不同的 target 单独配置不同的依赖项,同时引入公共 pods</span>
target <span class="token string">'targetA'</span> <span class="token keyword">do</span>
    commonPods
    pod <span class="token string">'SnapKit'</span>
<span class="token keyword">end</span>
    
target <span class="token string">'targetB'</span> <span class="token keyword">do</span>
    commonPods
    pod <span class="token string">'SwiftyJSON'</span>
<span class="token keyword">end</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br></div></div></section></div></div> <h2 id="常用指令"><a href="#常用指令" class="header-anchor">#</a> 常用指令</h2> <h3 id="搜索三方库"><a href="#搜索三方库" class="header-anchor">#</a> 搜索三方库</h3> <p>通过下面的指令我们可以搜索指定的三方库的信息</p> <div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code>pod search <span class="token constant">AFNetworking</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="更新本地依赖库列表"><a href="#更新本地依赖库列表" class="header-anchor">#</a> 更新本地依赖库列表</h3> <p>下面的指令可以更新 Pods 的本地依赖库，如果依赖库不是最新的那么有些新添加的库就无法通过  <code>pod search</code>  搜索到</p> <div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code>pod setup
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="安装依赖库"><a href="#安装依赖库" class="header-anchor">#</a> 安装依赖库</h3> <p>我们可以通过下面两种指令来安装依赖库</p> <div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code>pod install
<span class="token comment"># 或者</span>
pod update
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li><code>pod install</code>  会根据 Podfile 文件指定的内容去安装依赖库，如果存在 Podfile.lock 文件，则按该文件中指定的版本安装。这个方法有利于团队统一依赖库版本比较常用。</li> <li><code>pod update</code>  会根据 Podfile 文件对版本的描述获取最新依赖库的版本，如果 Podfile 中没有指定依赖库的安装版本则永远为最新版本，该指令会无视 Podfile.lock 文件。</li></ul> <h2 id="其他重要文件"><a href="#其他重要文件" class="header-anchor">#</a> 其他重要文件</h2> <h3 id="podfile-lock"><a href="#podfile-lock" class="header-anchor">#</a> Podfile.lock</h3> <p>第一次安装依赖库后 CocoaPods 会生成一个 Podfile.lock 文件，其中包含了当前项目中安装的依赖库的版本号，还包含了当前执行该命令的 CocoaPods 的版本号。当其他人通过  <code>pod install</code>  指令安装时会根据该文件中的版本号进行安装，有利于团队一致性。所以要把这个文件添加到版本管理中。</p> <h3 id="podspec"><a href="#podspec" class="header-anchor">#</a> Podspec</h3> <p>如果我们要制作自己的 CocosPod 库则需要创建该文件，这个文件描述了库的一些详细信息，其中具体的配置可以参阅<a href="https://guides.cocoapods.org/syntax/podspec.html#specification" target="_blank" rel="noopener noreferrer">官方文档<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></p> <p>这里可以参照 AFNetworking 的配置</p> <div class="language-ruby line-numbers-mode"><pre class="language-ruby"><code><span class="token constant">Pod</span><span class="token punctuation">:</span><span class="token punctuation">:</span><span class="token constant">Spec</span><span class="token punctuation">.</span><span class="token keyword">new</span> <span class="token class-name">do</span> <span class="token operator">|</span>s<span class="token operator">|</span>
  s<span class="token punctuation">.</span>name     <span class="token operator">=</span> <span class="token string">'AFNetworking'</span>
  s<span class="token punctuation">.</span>version  <span class="token operator">=</span> <span class="token string">'4.0.1'</span>
  s<span class="token punctuation">.</span>license  <span class="token operator">=</span> <span class="token string">'MIT'</span>
  s<span class="token punctuation">.</span>summary  <span class="token operator">=</span> <span class="token string">'A delightful networking framework for Apple platforms.'</span>
  s<span class="token punctuation">.</span>homepage <span class="token operator">=</span> <span class="token string">'https://github.com/AFNetworking/AFNetworking'</span>
  s<span class="token punctuation">.</span>social_media_url <span class="token operator">=</span> <span class="token string">'https://twitter.com/AFNetworking'</span>
  s<span class="token punctuation">.</span>authors  <span class="token operator">=</span> <span class="token punctuation">{</span> <span class="token string">'Mattt Thompson'</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token string">'m@mattt.me'</span> <span class="token punctuation">}</span>
  s<span class="token punctuation">.</span>source   <span class="token operator">=</span> <span class="token punctuation">{</span> <span class="token symbol">:git</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token string">'https://github.com/AFNetworking/AFNetworking.git'</span><span class="token punctuation">,</span> <span class="token symbol">:tag</span> <span class="token operator">=</span><span class="token operator">&gt;</span> s<span class="token punctuation">.</span>version <span class="token punctuation">}</span>


  s<span class="token punctuation">.</span>ios<span class="token punctuation">.</span>deployment_target <span class="token operator">=</span> <span class="token string">'9.0'</span>
  s<span class="token punctuation">.</span>osx<span class="token punctuation">.</span>deployment_target <span class="token operator">=</span> <span class="token string">'10.10'</span>
  s<span class="token punctuation">.</span>watchos<span class="token punctuation">.</span>deployment_target <span class="token operator">=</span> <span class="token string">'2.0'</span>
  s<span class="token punctuation">.</span>tvos<span class="token punctuation">.</span>deployment_target <span class="token operator">=</span> <span class="token string">'9.0'</span>

  s<span class="token punctuation">.</span>ios<span class="token punctuation">.</span>pod_target_xcconfig <span class="token operator">=</span> <span class="token punctuation">{</span> <span class="token string">'PRODUCT_BUNDLE_IDENTIFIER'</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token string">'com.alamofire.AFNetworking'</span> <span class="token punctuation">}</span>
  s<span class="token punctuation">.</span>osx<span class="token punctuation">.</span>pod_target_xcconfig <span class="token operator">=</span> <span class="token punctuation">{</span> <span class="token string">'PRODUCT_BUNDLE_IDENTIFIER'</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token string">'com.alamofire.AFNetworking'</span> <span class="token punctuation">}</span>
  s<span class="token punctuation">.</span>watchos<span class="token punctuation">.</span>pod_target_xcconfig <span class="token operator">=</span> <span class="token punctuation">{</span> <span class="token string">'PRODUCT_BUNDLE_IDENTIFIER'</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token string">'com.alamofire.AFNetworking-watchOS'</span> <span class="token punctuation">}</span>
  s<span class="token punctuation">.</span>tvos<span class="token punctuation">.</span>pod_target_xcconfig <span class="token operator">=</span> <span class="token punctuation">{</span> <span class="token string">'PRODUCT_BUNDLE_IDENTIFIER'</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token string">'com.alamofire.AFNetworking'</span> <span class="token punctuation">}</span>

  s<span class="token punctuation">.</span>source_files <span class="token operator">=</span> <span class="token string">'AFNetworking/AFNetworking.h'</span>

  s<span class="token punctuation">.</span>subspec <span class="token string">'Serialization'</span> <span class="token keyword">do</span> <span class="token operator">|</span>ss<span class="token operator">|</span>
    ss<span class="token punctuation">.</span>source_files <span class="token operator">=</span> <span class="token string">'AFNetworking/AFURL{Request,Response}Serialization.{h,m}'</span>
  <span class="token keyword">end</span>

  s<span class="token punctuation">.</span>subspec <span class="token string">'Security'</span> <span class="token keyword">do</span> <span class="token operator">|</span>ss<span class="token operator">|</span>
    ss<span class="token punctuation">.</span>source_files <span class="token operator">=</span> <span class="token string">'AFNetworking/AFSecurityPolicy.{h,m}'</span>
  <span class="token keyword">end</span>

  s<span class="token punctuation">.</span>subspec <span class="token string">'Reachability'</span> <span class="token keyword">do</span> <span class="token operator">|</span>ss<span class="token operator">|</span>
    ss<span class="token punctuation">.</span>ios<span class="token punctuation">.</span>deployment_target <span class="token operator">=</span> <span class="token string">'9.0'</span>
    ss<span class="token punctuation">.</span>osx<span class="token punctuation">.</span>deployment_target <span class="token operator">=</span> <span class="token string">'10.10'</span>
    ss<span class="token punctuation">.</span>tvos<span class="token punctuation">.</span>deployment_target <span class="token operator">=</span> <span class="token string">'9.0'</span>

    ss<span class="token punctuation">.</span>source_files <span class="token operator">=</span> <span class="token string">'AFNetworking/AFNetworkReachabilityManager.{h,m}'</span>
  <span class="token keyword">end</span>

  s<span class="token punctuation">.</span>subspec <span class="token string">'NSURLSession'</span> <span class="token keyword">do</span> <span class="token operator">|</span>ss<span class="token operator">|</span>
    ss<span class="token punctuation">.</span>dependency <span class="token string">'AFNetworking/Serialization'</span>
    ss<span class="token punctuation">.</span>ios<span class="token punctuation">.</span>dependency <span class="token string">'AFNetworking/Reachability'</span>
    ss<span class="token punctuation">.</span>osx<span class="token punctuation">.</span>dependency <span class="token string">'AFNetworking/Reachability'</span>
    ss<span class="token punctuation">.</span>tvos<span class="token punctuation">.</span>dependency <span class="token string">'AFNetworking/Reachability'</span>
    ss<span class="token punctuation">.</span>dependency <span class="token string">'AFNetworking/Security'</span>

    ss<span class="token punctuation">.</span>source_files <span class="token operator">=</span> <span class="token string">'AFNetworking/AF{URL,HTTP}SessionManager.{h,m}'</span><span class="token punctuation">,</span> <span class="token string">'AFNetworking/AFCompatibilityMacros.h'</span>
  <span class="token keyword">end</span>

  s<span class="token punctuation">.</span>subspec <span class="token string">'UIKit'</span> <span class="token keyword">do</span> <span class="token operator">|</span>ss<span class="token operator">|</span>
    ss<span class="token punctuation">.</span>ios<span class="token punctuation">.</span>deployment_target <span class="token operator">=</span> <span class="token string">'9.0'</span>
    ss<span class="token punctuation">.</span>tvos<span class="token punctuation">.</span>deployment_target <span class="token operator">=</span> <span class="token string">'9.0'</span>
    ss<span class="token punctuation">.</span>dependency <span class="token string">'AFNetworking/NSURLSession'</span>

    ss<span class="token punctuation">.</span>source_files <span class="token operator">=</span> <span class="token string">'UIKit+AFNetworking'</span>
  <span class="token keyword">end</span>
<span class="token keyword">end</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br></div></div><hr> <p>下面是发现的关于 CocoaPods 的好文章</p> <p><a href="https://mp.weixin.qq.com/mp/appmsgalbum?__biz=MzA5MTM1NTc2Ng==&amp;action=getalbum&amp;album_id=1477103239887142918&amp;scene=173&amp;from_msgid=2458322728&amp;from_itemidx=1&amp;count=3#wechat_redirect" target="_blank" rel="noopener noreferrer">CocoaPods 历险记<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></p> <hr></div> <footer class="page-edit" style="display:none;"><!----> <!----></footer> <!----> <!----></main> <!----> <div class="comments-wrapper" data-v-0cb1c278><div class="valine-wrapper"><div id="valine"></div></div></div></div></div></div></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-a81d141e data-v-a81d141e><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-a81d141e><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-a81d141e></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-a81d141e></path></svg></div><canvas id="vuepress-canvas-ribbon"></canvas><div class="my-popup" style="display:none;" data-v-3414bdeb><div class="my-popup-container" data-v-3414bdeb><div class="my-popup-exit" data-v-3414bdeb></div> <img src="" alt data-v-3414bdeb></div></div><div data-v-2ebabc0c></div><div class="kanbanniang" data-v-3b0f9b07><div class="banniang-container" style="display:;" data-v-3b0f9b07><div class="messageBox" style="right:68px;bottom:230px;display:none;" data-v-3b0f9b07>
      欢迎来到 KnightSama‘s Blog
    </div> <div class="operation" style="right:90px;bottom:40px;display:;" data-v-3b0f9b07><i class="kbnfont kbn-ban-home ban-home" data-v-3b0f9b07></i> <i class="kbnfont kbn-ban-message message" data-v-3b0f9b07></i> <i class="kbnfont kbn-ban-close close" data-v-3b0f9b07></i> <a target="_blank" href="https://vuepress-theme-reco.recoluan.com/views/plugins/kanbanniang.html" data-v-3b0f9b07><i class="kbnfont kbn-ban-info info" data-v-3b0f9b07></i></a> <i class="kbnfont kbn-ban-theme skin" style="display:;" data-v-3b0f9b07></i></div> <canvas id="banniang" width="200" height="260" class="live2d" style="right:90px;bottom:-20px;opacity:0.9;" data-v-3b0f9b07></canvas></div> <div class="showBanNiang" style="display:none;" data-v-3b0f9b07>
    看板娘
  </div></div></div></div>
    <script src="/assets/js/app.a2483de7.js" defer></script><script src="/assets/js/4.0078dadf.js" defer></script><script src="/assets/js/1.c3e7d2b0.js" defer></script><script src="/assets/js/14.c27d4a17.js" defer></script>
  </body>
</html>
